<html>
<head><meta charset="utf-8"><title>extend chalk `TypeName` with builtin types chalk#368 · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html">extend chalk `TypeName` with builtin types chalk#368</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192979203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/192979203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#192979203">(Apr 05 2020 at 21:30)</a>:</h4>
<p><span class="user-mention" data-user-id="281304">@Mark McCaskey</span> I took a look at your PR and made some initial comments. See my comment there, but I need to think a little bit about whether <code>TypeName</code> is <em>actually</em> a good place for these.</p>



<a name="193074386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193074386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193074386">(Apr 06 2020 at 17:29)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> Thanks!!  Your review has a lot of useful information in it.  It looks like I got a bit confused on some parts of it, I'll work on this some more tonight</p>



<a name="193821910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193821910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193821910">(Apr 13 2020 at 21:10)</a>:</h4>
<p>Hey!  Sorry I haven't made much progress on this recently: I'm a bit lost as to what the next steps are.  I think I can push through some more of the implementation of <code>Closure</code> (get it up to parity with <code>FnDef</code>), but other than that I'm not quite sure what to do.  It seems like this PR is touching on a number of non-trivial things that may require some design work.  Would it perhaps make sense to shift focus onto a new PR with the scalars first?  Alternatively,  this PR, as-is, has a decent amount of placeholder code so I can try to fill those parts in with proper implementations.</p>



<a name="193822011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822011">(Apr 13 2020 at 21:12)</a>:</h4>
<p><span class="user-mention" data-user-id="281304">@Mark McCaskey</span> I was thinking you could extract out the code for the scalars etc first</p>



<a name="193822049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822049">(Apr 13 2020 at 21:12)</a>:</h4>
<p>Agreed</p>



<a name="193822054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822054">(Apr 13 2020 at 21:12)</a>:</h4>
<p>and we can land that separately</p>



<a name="193822063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822063">(Apr 13 2020 at 21:12)</a>:</h4>
<p>and then come back to the fn-def/closures</p>



<a name="193822067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822067">(Apr 13 2020 at 21:12)</a>:</h4>
<p>But I also want to discuss this tomorrow before we land</p>



<a name="193822081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822081">(Apr 13 2020 at 21:12)</a>:</h4>
<p>one thing -- you will need to extend the parser I imagine with the appropriate keywords</p>



<a name="193822085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822085">(Apr 13 2020 at 21:12)</a>:</h4>
<p>or else we can't write tests for it</p>



<a name="193822100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822100">(Apr 13 2020 at 21:12)</a>:</h4>
<p>I forget if that was in the PR already</p>



<a name="193822114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822114">(Apr 13 2020 at 21:12)</a>:</h4>
<p>Mostly because I wonder if we want these types in <code>chalk-ir</code> or only in <code>chalk-rust-ir</code></p>



<a name="193822116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822116">(Apr 13 2020 at 21:12)</a>:</h4>
<p>i.e., <code>usize</code>, <code>bool</code>, and so forth</p>



<a name="193822135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822135">(Apr 13 2020 at 21:13)</a>:</h4>
<p>I think we want them in both</p>



<a name="193822147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822147">(Apr 13 2020 at 21:13)</a>:</h4>
<p>Great -- sounds good!  I removed it from the PR already, I can open a PR with the code I removed!</p>
<p>I started adding parsing for FnDef but it's super basic -- I'll thread the scalars through and do the same!</p>



<a name="193822161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822161">(Apr 13 2020 at 21:13)</a>:</h4>
<p>or at least .. I'm not sure what it looks like if they are only in chalk-rust-ir</p>



<a name="193822176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822176">(Apr 13 2020 at 21:13)</a>:</h4>
<p>certainly we have to generate special rules in chalk-solve for them</p>



<a name="193822194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822194">(Apr 13 2020 at 21:13)</a>:</h4>
<p>Right</p>



<a name="193822206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822206">(Apr 13 2020 at 21:13)</a>:</h4>
<p>and if -- as I hope -- chalk-ir eventually becomes the "standard IR for manipulating types" that is the foundation for type-checker, trait checking, etc</p>



<a name="193822213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822213">(Apr 13 2020 at 21:13)</a>:</h4>
<p>it'll need to be able to talk pleasantly about such types</p>



<a name="193822267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822267">(Apr 13 2020 at 21:14)</a>:</h4>
<p>Hmm</p>



<a name="193822277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822277">(Apr 13 2020 at 21:14)</a>:</h4>
<p>I wonder if it's worth merging chalk-ir and chalk-rust-ir</p>



<a name="193822289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822289">(Apr 13 2020 at 21:14)</a>:</h4>
<p>probably...not?</p>



<a name="193822321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822321">(Apr 13 2020 at 21:15)</a>:</h4>
<p>I .. yeah, I don't know.</p>



<a name="193822334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822334">(Apr 13 2020 at 21:15)</a>:</h4>
<p>I suspect not</p>



<a name="193822336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822336">(Apr 13 2020 at 21:15)</a>:</h4>
<p>But maybe</p>



<a name="193822371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822371">(Apr 13 2020 at 21:15)</a>:</h4>
<p>I'm already nearly persuaded that these types should go in chalk-ir</p>



<a name="193822373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822373">(Apr 13 2020 at 21:15)</a>:</h4>
<p>i.e, I think we could "tease out" the solver and have it depend only on chalk-ir</p>



<a name="193822386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822386">(Apr 13 2020 at 21:15)</a>:</h4>
<p>as well as stuff like "unification"</p>



<a name="193822388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822388">(Apr 13 2020 at 21:15)</a>:</h4>
<p>and subtyping</p>



<a name="193822392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822392">(Apr 13 2020 at 21:15)</a>:</h4>
<p>ah</p>



<a name="193822397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822397">(Apr 13 2020 at 21:15)</a>:</h4>
<p>yeah, possibly</p>



<a name="193822450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193822450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193822450">(Apr 13 2020 at 21:16)</a>:</h4>
<p>not sure how important that is, but there is some value in having those layers exposed via crate layering</p>



<a name="193852278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193852278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193852278">(Apr 14 2020 at 05:41)</a>:</h4>
<p>I started working on parsing scalars and opened a PR <a href="https://github.com/rust-lang/chalk/pull/394" title="https://github.com/rust-lang/chalk/pull/394">https://github.com/rust-lang/chalk/pull/394</a>!</p>
<p>I added parsing for integers and boolean literals, which I'm just now realizing may not be useful for this PR <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> ... did we just need to parse the type names?  Either way, I had fun writing that code.</p>
<p>I suppose I should ask for more clarification before writing any more code: does the "internal" implementation of these scalar types just consist of connecting them to the other "intrinsic" types like the built-in/well-known traits?</p>



<a name="193873744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/193873744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#193873744">(Apr 14 2020 at 09:54)</a>:</h4>
<p><span class="user-mention" data-user-id="281304">@Mark McCaskey</span> in this PR, I'd probably not touch the built-in traits, just add support for the types -- we could have some tests that let you e.g. write things like</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">S1</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">S1</span><span class="p">,</span><span class="w"> </span><span class="n">S1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>and then test a goal like <code>Implemented((S1, S2): Foo)</code> or whatever. (Same for <code>u32</code> and friends.)</p>



<a name="194259912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194259912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194259912">(Apr 16 2020 at 05:41)</a>:</h4>
<p>Thanks again for all guidance!  Unfortunately I didn't have as much time as I'd hoped to work on it tonight and wasn't able to finish.  I did write a few more tests though and some are passing when it seems like they should be failing.</p>
<p>An example of some surprising behavior I noticed is that given</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">A</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">B</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>, <code>(A, B): Foo</code> resolves as <code>Implemented(2&lt;A, B&gt;: Foo)</code> even though <code>A</code> and <code>B</code> are not the same type and even when <code>B</code> doesn't implement <code>Foo</code>.</p>
<p>This logic holds for structs too with:</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">C</span><span class="o">&lt;</span><span class="n">T1</span><span class="p">,</span><span class="w"> </span><span class="n">T2</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">C</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>in place of the tuple code causing <code>C&lt;A, B&gt;: Foo</code> to produce <code>Implemented(C&lt;A, B&gt;: Foo)</code>.</p>
<p>Is this correct behavior and I'm misunderstanding how this is supposed to work?</p>



<a name="194268160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194268160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194268160">(Apr 16 2020 at 07:57)</a>:</h4>
<p>Well, <code>(A,B): Foo</code> should be lowered as <code>Implemented((A, B): Foo)</code>, you just can't prove it</p>



<a name="194318631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194318631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194318631">(Apr 16 2020 at 15:08)</a>:</h4>
<p>Oh, okay -- thanks!  That makes sense then.  I thought it was asserting it, but it was just parsing the the query</p>



<a name="194320322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194320322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194320322">(Apr 16 2020 at 15:18)</a>:</h4>
<p>I left some comments btw on your PR</p>



<a name="194320335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194320335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194320335">(Apr 16 2020 at 15:18)</a>:</h4>
<p>that show how to run the tests you were trying to run</p>



<a name="194327516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194327516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194327516">(Apr 16 2020 at 16:01)</a>:</h4>
<p>Getting some test failures in <code>projection.rs</code> when I replaced <code>struct u32 { }</code> with the scalar u32:</p>
<div class="codehilite"><pre><span></span>---- test::projection::projection_equality stdout ----
program {
    trait Trait1 { type Type ; } trait Trait2 &lt; T &gt; { } impl &lt; T, U &gt; Trait2 &lt;
    T &gt; for U where U : Trait1 &lt; Type = T &gt; { } struct S { } impl Trait1 for S
    { type Type = u32 ; }
}
thread &#39;test::projection::projection_equality&#39; panicked at &#39;called `Result::unwrap()` on an `Err` value: ChalkError { error_text: &quot;trait impl for `Trait1` does not meet well-formedness requirements&quot; }&#39;, tests/test/mod.rs:227:19
</pre></div>


<p>Investigating this now, but haven't found a fix yet</p>



<a name="194333416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194333416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194333416">(Apr 16 2020 at 16:42)</a>:</h4>
<p>Okay, I think it might be because <code>WellFormed(u32)</code> fails!</p>



<a name="194334772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194334772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194334772">(Apr 16 2020 at 16:53)</a>:</h4>
<p>You probably need to add <code>WellFormed(T)</code> for most (all?) builtin types</p>



<a name="194336500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194336500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194336500">(Apr 16 2020 at 17:05)</a>:</h4>
<p>Huh, on the other hand, should that kind of reasoning live in the solver instead? Something like impls for well known traits that are only generated on demand? <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="194358571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194358571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194358571">(Apr 16 2020 at 19:54)</a>:</h4>
<p>WellFormed logic for builtin types should live in <code>chalk-solve</code></p>



<a name="194420507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194420507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194420507">(Apr 17 2020 at 10:23)</a>:</h4>
<p>left <a href="https://github.com/rust-lang/chalk/pull/394#pullrequestreview-395333283" title="https://github.com/rust-lang/chalk/pull/394#pullrequestreview-395333283">more detailed notes here</a></p>



<a name="194526853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194526853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark McCaskey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194526853">(Apr 18 2020 at 05:15)</a>:</h4>
<p>Thanks!</p>
<p>I'm working on implementing this now and am currently confused by <code>FromEnv</code>:</p>
<p>The existing logic for placeholders relies on <code>WellFormed(T) :- FromEnv(T)</code> (<code>builder.push_clause(WellFormed::Ty(ty.clone()), Some(FromEnv::Ty(ty.clone())));</code>), and scalar types don't currently satisfy <code>FromEnv</code>, so I split it out into a separate branch but I noticed that <code>builder.push_fact(FromEnv::Ty(ty.clone()));</code> doesn't make scalars satisfy <code>FromEnv</code>, even though <code>builder.push_fact(WellFormed::Ty(ty.clone()));</code> _does_ make them satisfy WellFormed</p>



<a name="194538294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194538294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194538294">(Apr 18 2020 at 10:50)</a>:</h4>
<p>Ah, that reminds me that our next meeting is about implied bounds, so I want to read over the various docs and bring that stuff back into my head</p>



<a name="194538375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194538375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194538375">(Apr 18 2020 at 10:52)</a>:</h4>
<p>That said, I actually think what you have is correct</p>



<a name="194538391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194538391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194538391">(Apr 18 2020 at 10:53)</a>:</h4>
<p>The idea of <code>FromEnv(...)</code> is that, as the name suggests, it is supposed to indicate something that you know is true because you are in a context where your caller (...assuming it's a fn) has proven it for you.</p>



<a name="194538398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194538398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194538398">(Apr 18 2020 at 10:53)</a>:</h4>
<p>In this case, we know that <code>u32</code> is well-formed from "first principles", so I think it is correct to just add a <code>WellFormed(u32)</code> fact.</p>



<a name="194538444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194538444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194538444">(Apr 18 2020 at 10:54)</a>:</h4>
<p>(In contrast, placeholder types are only known valid because we know that the caller won't supply us with an invalid one.)</p>



<a name="194586568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/extend%20chalk%20%60TypeName%60%20with%20builtin%20types%20chalk%23368/near/194586568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368.html#194586568">(Apr 19 2020 at 08:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368/near/194538294" title="#narrow/stream/144729-wg-traits/topic/extend.20chalk.20.60TypeName.60.20with.20builtin.20types.20chalk.23368/near/194538294">said</a>:</p>
<blockquote>
<p>Ah, that reminds me that our next meeting is about implied bounds, so I want to read over the various docs and bring that stuff back into my head</p>
</blockquote>
<p>That would be mostly the <a href="https://github.com/rust-lang/rfcs/blob/master/text/2089-implied-bounds.md" title="https://github.com/rust-lang/rfcs/blob/master/text/2089-implied-bounds.md">RFC</a> and the <a href="https://rustc-dev-guide.rust-lang.org/traits/implied-bounds.html" title="https://rustc-dev-guide.rust-lang.org/traits/implied-bounds.html">rustc-dev-guide chapter</a>, right?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>